package com.shiwenping.reply.data;

import android.content.Context;

import com.shiwenping.reply.data.local.LocalDataSource;
import com.shiwenping.reply.data.remote.RemoteDataSource;
import com.shiwenping.reply.net.domain.FaqItemResult;
import com.shiwenping.reply.net.domain.FileItemResult;

import java.util.List;

import rx.Observable;
import rx.Scheduler;
import rx.schedulers.Schedulers;

/**
 * @author shiwenping
 * @date 17-11-10 上午11:14
 */

public class Repository implements DataSource {
    private DataSource localDataSource;
    private DataSource remoteDataSource;

    public static Repository getRepository(Context mContext) {
        return new Repository(new LocalDataSource(), new RemoteDataSource(mContext));
    }

    private Repository(DataSource localDataSource, DataSource remoteDataSource) {
        this.localDataSource = localDataSource;
        this.remoteDataSource = remoteDataSource;
    }


    public Observable<List<FaqItemResult>> getFaqList(boolean isLocal) {
        return (isLocal ? localDataSource:remoteDataSource).getFaqList(isLocal,"");
    }


    public Observable<List<FileItemResult>> getFileList(boolean isLocal) {
        return (isLocal ? localDataSource:remoteDataSource).getFileList(isLocal,"");
    }

    @Override
    public Observable<List<FaqItemResult>> getFaqList(boolean isLocal, String cateName) {
        return (isLocal ? localDataSource : remoteDataSource).getFaqList(isLocal, cateName);
    }

    @Override
    public Observable<List<FileItemResult>> getFileList(boolean isLocal, String cateName) {
        return (isLocal ? localDataSource : remoteDataSource).getFileList(isLocal, cateName);
    }
}
